/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.Assignment;
import bpmn.BpmnPackage;
import bpmn.Gate;
import bpmn.SequenceFlow;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Gate</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.GateImpl#getOutgoingSequenceFlow <em>Outgoing Sequence Flow</em>}</li>
 *   <li>{@link bpmn.impl.GateImpl#getAssignments <em>Assignments</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GateImpl extends SupportingElementImpl implements Gate {
	/**
	 * The cached value of the '{@link #getOutgoingSequenceFlow() <em>Outgoing Sequence Flow</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutgoingSequenceFlow()
	 * @generated
	 * @ordered
	 */
	protected SequenceFlow outgoingSequenceFlow;

	/**
	 * The cached value of the '{@link #getAssignments() <em>Assignments</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssignments()
	 * @generated
	 * @ordered
	 */
	protected EList<Assignment> assignments;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GateImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.GATE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SequenceFlow getOutgoingSequenceFlow() {
		if (outgoingSequenceFlow != null && outgoingSequenceFlow.eIsProxy()) {
			InternalEObject oldOutgoingSequenceFlow = (InternalEObject)outgoingSequenceFlow;
			outgoingSequenceFlow = (SequenceFlow)eResolveProxy(oldOutgoingSequenceFlow);
			if (outgoingSequenceFlow != oldOutgoingSequenceFlow) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.GATE__OUTGOING_SEQUENCE_FLOW, oldOutgoingSequenceFlow, outgoingSequenceFlow));
			}
		}
		return outgoingSequenceFlow;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SequenceFlow basicGetOutgoingSequenceFlow() {
		return outgoingSequenceFlow;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutgoingSequenceFlow(SequenceFlow newOutgoingSequenceFlow) {
		SequenceFlow oldOutgoingSequenceFlow = outgoingSequenceFlow;
		outgoingSequenceFlow = newOutgoingSequenceFlow;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.GATE__OUTGOING_SEQUENCE_FLOW, oldOutgoingSequenceFlow, outgoingSequenceFlow));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Assignment> getAssignments() {
		if (assignments == null) {
			assignments = new EObjectResolvingEList<Assignment>(Assignment.class, this, BpmnPackage.GATE__ASSIGNMENTS);
		}
		return assignments;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.GATE__OUTGOING_SEQUENCE_FLOW:
				if (resolve) return getOutgoingSequenceFlow();
				return basicGetOutgoingSequenceFlow();
			case BpmnPackage.GATE__ASSIGNMENTS:
				return getAssignments();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.GATE__OUTGOING_SEQUENCE_FLOW:
				setOutgoingSequenceFlow((SequenceFlow)newValue);
				return;
			case BpmnPackage.GATE__ASSIGNMENTS:
				getAssignments().clear();
				getAssignments().addAll((Collection<? extends Assignment>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.GATE__OUTGOING_SEQUENCE_FLOW:
				setOutgoingSequenceFlow((SequenceFlow)null);
				return;
			case BpmnPackage.GATE__ASSIGNMENTS:
				getAssignments().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.GATE__OUTGOING_SEQUENCE_FLOW:
				return outgoingSequenceFlow != null;
			case BpmnPackage.GATE__ASSIGNMENTS:
				return assignments != null && !assignments.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //GateImpl
